/**
 * com.chaeron.GPS - An API for access to GPS devices.
 *
 *
 * Copyright (c) 2001, 2002 Chaeron Corporation,
 * All rights reserved.
 * 
 * Chaeron grants you a non-exclusive license to use, modify and re-distribute
 * this program under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version, provided that this copyright notice and 
 * license appear on all copies of the software.
 * 
 * Software is provided "AS IS," without a warranty of any kind. ALL EXPRESS OR
 * IMPLIED REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE
 * HEREBY EXCLUDED. THE ENTIRE RISK ARISING OUT OF USING THE SOFTWARE IS ASSUMED
 * BY THE LICENSEE. See the GNU General Public License for more details.
 *
 * CHAERON AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY
 * LICENSEE OR ANY THIRD PARTY AS A RESULT OF USING OR DISTRIBUTING SOFTWARE.
 * IN NO EVENT WILL CHAERON OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE,
 * PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL
 * OR PUNITIVE DAMAGES, HOWEVER CAUSED AN REGARDLESS OF THE THEORY OF LIABILITY,
 * ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF CHAERON HAS
 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

 * @version     1.02
 * @author      Andrzej Jan Taramina, Chaeron Corporation
 *              andrzej@chaeron.com
 */

package com.chaeron.GPS.Garmin;

//***************************************************************************
//*
//*     Imports
//*
//***************************************************************************/

import com.chaeron.GPS.*;
import com.chaeron.GPS.event.*;
import com.chaeron.GPS.exception.*;

import com.chaeron.platform.common.*;


//***************************************************************************
//*
//*     GarminTrackLog Class definition
//*
//***************************************************************************/

/**
 * The GarminTrackLog class represents Garmin Routes
 *
 */

public class GarminTrackLog implements GPSTrackLog
{
	//***************************************************************************
	//*
	//*     Constant definitions
	//*
	//***************************************************************************/
	
	//***************************************************************************
	//*
	//*     Attributes
	//*
	//***************************************************************************/
	
	private TrackHeaderGarminPacket		header				= null;
	private Vector						points				= null;
	private int							methodsImplemented 	= 0;
	
	
	//***************************************************************************
	//*
	//*     Constructors
	//*
	//***************************************************************************/
	
	/**
	 * Create a default GarminTrackLog instance
	 */
	
	public GarminTrackLog()
	{  
		
	}
	
	
	//***************************************************************************
	//*
	//*   Garmin package Methods
	//*
	//***************************************************************************/
	
	/**
	 * Set header packet
	 *
	 * @param	header		header packet
	 */
	
	void setHeader( TrackHeaderGarminPacket header )
	{
		this.header = header;
		
		int	headerMethods	= GPSTrackLog.TRACKLOG_METHOD_DISPLAY | GPSTrackLog.TRACKLOG_METHOD_IDENTIFICATION | GPSTrackLog.TRACKLOG_METHOD_COLOUR;	
		
		if( header != null ) {
			setMethodsImplemented( getMethodsImplemented() | headerMethods );
		} else {
			setMethodsImplemented( getMethodsImplemented() & ~headerMethods );
		}
	}
	
	
	/**
	 * Set track points
	 *
	 * @param	waypoints		vector of track points
	 */
	
	void setPoints( Vector points )
	{
		this.points = points;
		
		if( points != null ) {
			setMethodsImplemented( getMethodsImplemented() | GPSTrackLog.TRACKLOG_METHOD_TRACKPOINTS );
		} else {
			setMethodsImplemented( getMethodsImplemented() & ~GPSTrackLog.TRACKLOG_METHOD_TRACKPOINTS );
		}
	}
	
	
	//***************************************************************************
	//*
	//*   Public Route Methods
	//*
	//***************************************************************************/
	
	/**
	 * Get the Display value
	 *
	 * @return		Display on map?
	 */
	
	public boolean getDisplay()
	{  
		boolean display = false;
		
		if( header != null ) {
			display = header.getDisplay();
		}
		
		return( display );
	}
	
	
	/**
	 * Get the Colour
	 *
	 * @return		colour
	 */
	
	public byte getColour()
	{  
		byte colour = (byte)0;
		
		if( header != null ) {
			colour = header.getColour();
		}
		
		return( colour );
	}
	
	
	/**
	 * Get the Identification String
	 *
	 * @return		Identification String
	 */
	
	public String getIdentification()
	{  
		String id = "";
		
		if( header != null ) {
			id = header.getIdentification();
		}
		
		return( id );
	}
	
	
	/**
	 * Get the track points
	 *
	 * @return		track points
	 */
	
	public Vector getTrackPoints()
	{
		return( points );
	}
	
	//***************************************************************************
	//*
	//*    GPSValue Methods
	//*
	//***************************************************************************/
	
	/**
	 * Get the Methods Implemented flags
	 *
	 * @return		methods implemented flags
	 */
	
	public int getMethodsImplemented() 
	{
		return( methodsImplemented );
	}
	
	/**
	 * Set the methodsImplemented flags
	 *
	 * @param	flags	field flags
	 */
	
	public void setMethodsImplemented( int flags ) 
	{
		methodsImplemented = flags;
	}
	
	/**
	 * Test if a method is implemented
	 *
	 * @param	methodFlag	method to test
	 */
	
	public boolean isMethodImplemented( int methodFlag )
	{
		return( ( methodsImplemented & methodFlag ) != 0 );
	}
	
	/**
	 * Return this Event Value as XML
	 *
	 * @return Event Value as XML
	 */
	
	public String toXML() 
	{
		return( "" );
	}
	
	/**
	 * Return this Event Value as XML
	 *
	 * @param declaration include XML Declaration at start?
	 * @param namespace include XML namespace at start?
	 * @return Event Value as XML
	 */
	
	public String toXML( boolean declaration, boolean namespace )
	{
		return( "" );
	}
	
	/**
	 * Write this Event Value as XML to a catalog
	 *
	 * @param catalog	catalog to write to.
	 */
	
	public void toXML( Catalog catalog ) 
	{
	}
	
	/**
	 * Write this Event Value as XML to a catalog
	 *
	 * @param catalog	catalog to write to.
	 * @param declaration include XML Declaration at start?
	 * @param namespace include XML namespace at start?
	 */
	
	public void toXML( Catalog catalog, boolean declaration, boolean namespace ) 
	{
	}
	
}
